<template>
    <h3>经营数据</h3>
    <n-space class="topdata" vertical>
        <n-form :model="initJinyingData" label-placement="left" label-width="120">
            <n-descriptions label-placement="top" bordered :column="4">
                <n-descriptions-item :label="item.title" v-for="(item, index) in initJinyingData" :key="index">
                    <n-form-item :label="item.title">
                        <n-space align="center">
                            <n-input-number size="small" v-model:value="item.val" :style="{ width: '100px' }" />{{
            uetUter(item.val) }}<n-switch size="small" v-model:value="item.val_status" />
                        </n-space>
                    </n-form-item>
                    <n-form-item label="昨日">
                        <n-space align="center">
                            <n-radio-group size="small" v-model:value="item.icon_type" name="radiobuttongroup1">
                                <n-radio-button v-for="song in songs" :key="song.value" :value="song.value"
                                    :label="song.label" />
                            </n-radio-group>
                            <n-switch size="small" v-model:value="item.icon_type_status" />
                        </n-space>

                    </n-form-item>
                    <n-form-item label="%">
                        <n-space align="center">

                            <n-input-number size="small" v-model:value="item.sub_val"
                                :style="{ width: '100px' }" />%<n-switch size="small"
                                v-model:value="item.sub_val_status" />
                        </n-space>

                    </n-form-item>
                </n-descriptions-item>
            </n-descriptions>
        </n-form>
        <n-space>
            <n-button strong secondary type="success" @click="savaDataInStorege('initJinyingData', initJinyingData.map((item: any) => {
            item.val_show_tab = uetUter(item.val)
            item.sub_val_show = item.icon_type == '0' ? '-' : item.sub_val + '%'
            // item.icon_type_show = item.icon_type == '17' ? '↑' : item.icon_type == '18' ? '↓' : '一'
            return item
        }))">
                保存
            </n-button>
            <n-switch size="small" v-model:value="showAllconter" @update-value="chengeDataFunc" />
        </n-space>
    </n-space>
</template>


<script lang="ts" setup>
import { NDescriptions, NDescriptionsItem, NForm, NFormItem, NInputNumber, NSpace, NButton, NSwitch, NRadioButton, NRadioGroup } from 'naive-ui'
import { inject } from 'vue'
import { ref } from 'vue'
import { uetUter } from './setUter.ts'
const { initJinyingData, savaDataInStorege } = inject('initJinyingData') as any

const showAllconter = ref(true)
const songs = [{
    value: '17',
    label: '升'
}, {
    value: '0',
    label: '平'
}, {
    value: '18',
    label: '下降'
}]


function chengeDataFunc() {
    console.log('showAllconter', showAllconter.value)
    initJinyingData.value.forEach((item: any) => {
        console.log('item', item)
        item.val_status = showAllconter.value
        item.sub_val_status = showAllconter.value
        item.icon_type_status = showAllconter.value
    })
}


</script>
<style scoped></style>